﻿Imports System
Imports System.IO
Imports System.Data.SqlServerCe
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.Common

Module CouponSystemDao

    Public Function findCouponSystems(ByVal couponBarcode As String) As DataTable
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()

        Dim SQL As String = "SELECT couponSystem.SYSTEM_ID, couponSystem.COUPON_BARCODE, couponSystem.SYSTEM_TYPE_ID, systemType.SYSTEM_TYPE_NAME " & _
                  " FROM eqam_coupon_system couponSystem " & _
                  "     LEFT JOIN eqam_system_type systemType ON couponSystem.SYSTEM_TYPE_ID = systemType.SYSTEM_TYPE_ID  " & _
                  " WHERE 1=1 "

        If (couponBarcode IsNot Nothing And couponBarcode <> "") Then
            SQL = SQL & " AND couponSystem.COUPON_BARCODE = @COUPON_BARCODE"
            paramList.Add("@COUPON_BARCODE", couponBarcode)
        End If

        SQL = SQL & " GROUP BY couponSystem.SYSTEM_ID, couponSystem.COUPON_BARCODE, couponSystem.SYSTEM_TYPE_ID, systemType.SYSTEM_TYPE_NAME"

        Return LoadData(SQL, paramList)
    End Function

End Module
